package com.kob.backend.controller.TempAndHumidity;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/temperature")
public class TempController {
    /**
     * 前端直接得到txt文件
     * @return OBJ类型 url地址
     * @throws MalformedURLException
     */
    @GetMapping("/gettemp")
    public Map<String,Object> GetTemp() throws MalformedURLException {
        String str = "https://packetmqf3.oss-cn-chengdu.aliyuncs.com/TempAndHumidity.txt";
        URL url = new URL(str);
        Map<String,Object> res = new HashMap<>();
        res.put("url",url);
        return res;
    }
}
